﻿using System;
using System.Xml;

namespace OptiGear1
{
    public class XmlDoc : XmlDocument
    {
        public XmlDoc(XmlDocument doc)
        {
            base.LoadXml(doc.OuterXml);
        }

        public XmlDoc()
        {
        }

        public string GetNodeValueIfExists(string xpath)
        {
            try
            {
                return base.SelectSingleNode(xpath).InnerText;
            }
            catch (Exception)
            {
                return null;
            }
        }

        public string GetNodeValue(string xpath)
        {
            try
            {
                return base.SelectSingleNode(xpath).InnerText;
            }
            catch (Exception)
            {
                throw new Exception("Path '" + xpath + "' not found");
            }
        }
    }

}